package org.nestor.demo.protobuf;

import static io.grpc.MethodDescriptor.generateFullMethodName;

/**
 * <pre>
 * gRPC服务，这是个在线商城的订单查询服务
 * </pre>
 */
@javax.annotation.Generated(
    value = "by gRPC proto compiler (version 1.42.0)",
    comments = "Source: order-client-stream.proto")
@io.grpc.stub.annotations.GrpcGenerated
public final class OrderQueryClientStreamGrpc {

  private OrderQueryClientStreamGrpc() {}

  public static final String SERVICE_NAME = "protobuf_demo.OrderQueryClientStream";

  // Static method descriptors that strictly reflect the proto.
  private static volatile io.grpc.MethodDescriptor<Buyer,
      Order> getListOrdersMethod;

  @io.grpc.stub.annotations.RpcMethod(
      fullMethodName = SERVICE_NAME + '/' + "ListOrders",
      requestType = Buyer.class,
      responseType = Order.class,
      methodType = io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING)
  public static io.grpc.MethodDescriptor<Buyer,
      Order> getListOrdersMethod() {
    io.grpc.MethodDescriptor<Buyer, Order> getListOrdersMethod;
    if ((getListOrdersMethod = OrderQueryClientStreamGrpc.getListOrdersMethod) == null) {
      synchronized (OrderQueryClientStreamGrpc.class) {
        if ((getListOrdersMethod = OrderQueryClientStreamGrpc.getListOrdersMethod) == null) {
          OrderQueryClientStreamGrpc.getListOrdersMethod = getListOrdersMethod =
              io.grpc.MethodDescriptor.<Buyer, Order>newBuilder()
              .setType(io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING)
              .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListOrders"))
              .setSampledToLocalTracing(true)
              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  Buyer.getDefaultInstance()))
              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  Order.getDefaultInstance()))
              .setSchemaDescriptor(new OrderQueryClientStreamMethodDescriptorSupplier("ListOrders"))
              .build();
        }
      }
    }
    return getListOrdersMethod;
  }

  /**
   * Creates a new async stub that supports all call types for the service
   */
  public static OrderQueryClientStreamStub newStub(io.grpc.Channel channel) {
    io.grpc.stub.AbstractStub.StubFactory<OrderQueryClientStreamStub> factory =
      new io.grpc.stub.AbstractStub.StubFactory<OrderQueryClientStreamStub>() {
        @Override
        public OrderQueryClientStreamStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
          return new OrderQueryClientStreamStub(channel, callOptions);
        }
      };
    return OrderQueryClientStreamStub.newStub(factory, channel);
  }

  /**
   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
   */
  public static OrderQueryClientStreamBlockingStub newBlockingStub(
      io.grpc.Channel channel) {
    io.grpc.stub.AbstractStub.StubFactory<OrderQueryClientStreamBlockingStub> factory =
      new io.grpc.stub.AbstractStub.StubFactory<OrderQueryClientStreamBlockingStub>() {
        @Override
        public OrderQueryClientStreamBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
          return new OrderQueryClientStreamBlockingStub(channel, callOptions);
        }
      };
    return OrderQueryClientStreamBlockingStub.newStub(factory, channel);
  }

  /**
   * Creates a new ListenableFuture-style stub that supports unary calls on the service
   */
  public static OrderQueryClientStreamFutureStub newFutureStub(
      io.grpc.Channel channel) {
    io.grpc.stub.AbstractStub.StubFactory<OrderQueryClientStreamFutureStub> factory =
      new io.grpc.stub.AbstractStub.StubFactory<OrderQueryClientStreamFutureStub>() {
        @Override
        public OrderQueryClientStreamFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
          return new OrderQueryClientStreamFutureStub(channel, callOptions);
        }
      };
    return OrderQueryClientStreamFutureStub.newStub(factory, channel);
  }

  /**
   * <pre>
   * gRPC服务，这是个在线商城的订单查询服务
   * </pre>
   */
  public static abstract class OrderQueryClientStreamImplBase implements io.grpc.BindableService {

    /**
     * <pre>
     * 服务端流式：订单列表接口，入参是买家信息，返回订单列表(用stream修饰返回值)
     * </pre>
     */
    public io.grpc.stub.StreamObserver<Buyer> listOrders(
        io.grpc.stub.StreamObserver<Order> responseObserver) {
      return io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall(getListOrdersMethod(), responseObserver);
    }

    @Override public final io.grpc.ServerServiceDefinition bindService() {
      return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
          .addMethod(
            getListOrdersMethod(),
            io.grpc.stub.ServerCalls.asyncClientStreamingCall(
              new MethodHandlers<
                Buyer,
                Order>(
                  this, METHODID_LIST_ORDERS)))
          .build();
    }
  }

  /**
   * <pre>
   * gRPC服务，这是个在线商城的订单查询服务
   * </pre>
   */
  public static final class OrderQueryClientStreamStub extends io.grpc.stub.AbstractAsyncStub<OrderQueryClientStreamStub> {
    private OrderQueryClientStreamStub(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected OrderQueryClientStreamStub build(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      return new OrderQueryClientStreamStub(channel, callOptions);
    }

    /**
     * <pre>
     * 服务端流式：订单列表接口，入参是买家信息，返回订单列表(用stream修饰返回值)
     * </pre>
     */
    public io.grpc.stub.StreamObserver<Buyer> listOrders(
        io.grpc.stub.StreamObserver<Order> responseObserver) {
      return io.grpc.stub.ClientCalls.asyncClientStreamingCall(
          getChannel().newCall(getListOrdersMethod(), getCallOptions()), responseObserver);
    }
  }

  /**
   * <pre>
   * gRPC服务，这是个在线商城的订单查询服务
   * </pre>
   */
  public static final class OrderQueryClientStreamBlockingStub extends io.grpc.stub.AbstractBlockingStub<OrderQueryClientStreamBlockingStub> {
    private OrderQueryClientStreamBlockingStub(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected OrderQueryClientStreamBlockingStub build(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      return new OrderQueryClientStreamBlockingStub(channel, callOptions);
    }
  }

  /**
   * <pre>
   * gRPC服务，这是个在线商城的订单查询服务
   * </pre>
   */
  public static final class OrderQueryClientStreamFutureStub extends io.grpc.stub.AbstractFutureStub<OrderQueryClientStreamFutureStub> {
    private OrderQueryClientStreamFutureStub(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected OrderQueryClientStreamFutureStub build(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      return new OrderQueryClientStreamFutureStub(channel, callOptions);
    }
  }

  private static final int METHODID_LIST_ORDERS = 0;

  private static final class MethodHandlers<Req, Resp> implements
      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
    private final OrderQueryClientStreamImplBase serviceImpl;
    private final int methodId;

    MethodHandlers(OrderQueryClientStreamImplBase serviceImpl, int methodId) {
      this.serviceImpl = serviceImpl;
      this.methodId = methodId;
    }

    @Override
    @SuppressWarnings("unchecked")
    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        default:
          throw new AssertionError();
      }
    }

    @Override
    @SuppressWarnings("unchecked")
    public io.grpc.stub.StreamObserver<Req> invoke(
        io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        case METHODID_LIST_ORDERS:
          return (io.grpc.stub.StreamObserver<Req>) serviceImpl.listOrders(
              (io.grpc.stub.StreamObserver<Order>) responseObserver);
        default:
          throw new AssertionError();
      }
    }
  }

  private static abstract class OrderQueryClientStreamBaseDescriptorSupplier
      implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
    OrderQueryClientStreamBaseDescriptorSupplier() {}

    @Override
    public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
      return org.nestor.demo.protobuf.MallClientStreamProto.getDescriptor();
    }

    @Override
    public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
      return getFileDescriptor().findServiceByName("OrderQueryClientStream");
    }
  }

  private static final class OrderQueryClientStreamFileDescriptorSupplier
      extends OrderQueryClientStreamBaseDescriptorSupplier {
    OrderQueryClientStreamFileDescriptorSupplier() {}
  }

  private static final class OrderQueryClientStreamMethodDescriptorSupplier
      extends OrderQueryClientStreamBaseDescriptorSupplier
      implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
    private final String methodName;

    OrderQueryClientStreamMethodDescriptorSupplier(String methodName) {
      this.methodName = methodName;
    }

    @Override
    public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
      return getServiceDescriptor().findMethodByName(methodName);
    }
  }

  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;

  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
    io.grpc.ServiceDescriptor result = serviceDescriptor;
    if (result == null) {
      synchronized (OrderQueryClientStreamGrpc.class) {
        result = serviceDescriptor;
        if (result == null) {
          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
              .setSchemaDescriptor(new OrderQueryClientStreamFileDescriptorSupplier())
              .addMethod(getListOrdersMethod())
              .build();
        }
      }
    }
    return result;
  }
}
